package com.yhert.study.springcloud.study01.gateway.server;

import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

@EnableDiscoveryClient
@SpringCloudApplication
//@EnableFeignClients
//@EnableHystrix
//@EnableEurekaClient
@RefreshScope
public class StartMain {

	public static void main(String[] args) {
		SpringApplication.run(StartMain.class, args);
	}

//	@Bean
//	public ServerCodecConfigurer buildServerCodecConfigurer() {
//		return new DefaultServerCodecConfigurer();
//	}

	@Bean
	public RouteLocator myRouters(RouteLocatorBuilder builder) {
		return builder.routes().route(p -> p.path("/su/**").uri("https://www.baidu.com"))
				.route(p -> p.path("/sa/**").uri("lb://serviceAccount"))
				.route(p -> p.path("/sac/**").uri("lb://serviceAccount")).build();
	}

//	@Bean
//	public RouteLocator myRoutes(RouteLocatorBuilder builder) {
//		return builder.routes().route(
//				p -> p.path("/get").filters(f -> f.addRequestHeader("Hello", "World")).uri("https://www.baidu.com"))
//				.build();
//	}

}
